package View;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFormattedTextField;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;

import Controller.AddUser;



@SuppressWarnings("serial")
public class PanelRegistrationForm extends JPanel{
	
	private static PanelRegistrationForm single;
	
	private JLabel formName = new JLabel("Registratie formulier");
	private JLabel name = new JLabel("* Voornaam: ");
	private JLabel insertion = new JLabel("Tussenvoegsel: ");
	private JLabel surname = new JLabel("* Achternaam: ");
	private JLabel emailAdres = new JLabel("* E-mailadres: ");
	private JLabel phonenumber = new JLabel("Telefoonnummer: ");
	private JLabel adres = new JLabel("Adres: ");
	private JLabel zipcode = new JLabel("Postcode: ");
	private JLabel city = new JLabel("Woonplaats: ");
	private JLabel password = new JLabel("* Wachtwoord: ");
	private JLabel confirmPassword = new JLabel("* Bevestig wachtwoord: ");
	private JLabel required = new JLabel("Velden met een * zijn verplicht");
	
	private JTextField nameField = new JTextField();
	private JTextField insertionField = new JTextField();
	private JTextField surenameField = new JTextField();
	private JTextField emailField = new JTextField();
	private JFormattedTextField phoneField = new JFormattedTextField();
	private JTextField adresField = new JTextField();
	private JTextField zipcodeField = new JTextField();
	private JTextField cityField = new JTextField();
	
	private JPasswordField passwordField = new JPasswordField();
	private JPasswordField confirmPassField = new JPasswordField();
	
	private JButton confirmButton = new JButton("Bevestigen");
	private JButton cancelButton = new JButton("Annuleren");
	
	private Color backcolor = new Color(159, 158, 157);
	private Color titleColor = new Color(65, 65, 65);
	
	private Font titleFont = new Font("Serif", Font.BOLD, 30);
	private Font requiredFont = new Font("Serif", Font.ITALIC, 11);
	
	private AddUser ag = new AddUser(this);
	
	private PanelRegistrationForm() {
		
		
		
		setLayout(null);
		setBackground(backcolor);
		
	      formName.setBounds(200, 40, 400, 30);
	      formName.setForeground(titleColor);
	      formName.setFont(titleFont);
	      
	      name.setBounds(70, 90, 200, 30);
	      insertion.setBounds(80, 130, 200, 30);
	      surname.setBounds(70, 170, 200, 30);
	      emailAdres.setBounds(70, 210, 200, 30);
	      phonenumber.setBounds(80, 250, 200, 30);
	      adres.setBounds(80, 290, 200, 30);
	      zipcode.setBounds(80, 330, 200, 30);
	      city.setBounds(80, 370, 200, 30);
	      password.setBounds(70, 410, 200, 30);
	      confirmPassword.setBounds(70, 450, 200, 30);
	      required.setBounds(30, 600, 200, 30);
	      required.setFont(requiredFont);
	      
	      nameField.setBounds(300, 90, 200, 30);
	      insertionField.setBounds(300, 130, 200, 30);
	      surenameField.setBounds(300, 170, 200, 30);
	      emailField.setBounds(300, 210, 200, 30);
	      phoneField.setBounds(300, 250, 200, 30);
	      adresField.setBounds(300, 290, 200, 30);
	      zipcodeField.setBounds(300, 330, 200, 30);
	      cityField.setBounds(300, 370, 200, 30);
	      passwordField.setBounds(300, 410, 200, 30);
	      confirmPassField.setBounds(300, 450, 200, 30);
	      
	      confirmButton.setBounds(200, 540, 100, 30);
	      confirmButton.setActionCommand("confirm");
	      confirmButton.addActionListener(ag);
	      cancelButton.setBounds(320, 540, 100, 30);
	      cancelButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				PopUpFrame rf = PopUpFrame.getInstance();
				selfDestroy();
				rf.dispose();
			}
		});
	      
	     
	      add(formName);
	      add(name);
	      add(insertion);
	      add(surname);
	      add(emailAdres);
	      add(phonenumber);
	      add(adres);
	      add(zipcode);
	      add(city);
	      add(password);
	      add(confirmPassword);
	      add(required);
	      
	      add(nameField);
	      add(insertionField);
	      add(surenameField);
	      add(emailField);
	      add(phoneField);
	      add(adresField);
	      add(zipcodeField);
	      add(cityField);
	      
	      add(confirmButton);
	      add(cancelButton);
	      
	      add(passwordField);
	      add(confirmPassField);
		
	}

	public static PanelRegistrationForm getInstance() {
		if(single == null){
			single = new PanelRegistrationForm();
		}
		return single;
	}
	
	public static void selfDestroy(){
		single = null;
	}

	public JLabel getFormName() {
		return formName;
	}

	public void setFormName(JLabel formName) {
		this.formName = formName;
	}

	public JLabel getInsertion() {
		return insertion;
	}

	public void setInsertion(JLabel insertion) {
		this.insertion = insertion;
	}

	public JLabel getSurname() {
		return surname;
	}

	public void setSurname(JLabel surname) {
		this.surname = surname;
	}

	public JLabel getEmailAdres() {
		return emailAdres;
	}

	public void setEmailAdres(JLabel emailAdres) {
		this.emailAdres = emailAdres;
	}

	public JLabel getPhonenumber() {
		return phonenumber;
	}

	public void setPhonenumber(JLabel phonenumber) {
		this.phonenumber = phonenumber;
	}

	public JLabel getAdres() {
		return adres;
	}

	public void setAdres(JLabel adres) {
		this.adres = adres;
	}

	public JLabel getZipcode() {
		return zipcode;
	}

	public void setZipcode(JLabel zipcode) {
		this.zipcode = zipcode;
	}

	public JLabel getCity() {
		return city;
	}

	public void setCity(JLabel city) {
		this.city = city;
	}

	public JLabel getPassword() {
		return password;
	}

	public void setPassword(JLabel password) {
		this.password = password;
	}

	public JLabel getConfirmPassword() {
		return confirmPassword;
	}

	public void setConfirmPassword(JLabel confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	public JTextField getNameField() {
		return nameField;
	}

	public void setNameField(JTextField nameField) {
		this.nameField = nameField;
	}

	public JTextField getInsertionField() {
		return insertionField;
	}

	public void setInsertionField(JTextField insertionField) {
		this.insertionField = insertionField;
	}

	public JTextField getSurnameField() {
		return surenameField;
	}

	public void setSurnameField(JTextField surnameField) {
		this.surenameField = surnameField;
	}

	public JTextField getEmailField() {
		return emailField;
	}

	public void setEmailField(JTextField emailField) {
		this.emailField = emailField;
	}

	public JFormattedTextField getPhoneField() {
		return phoneField;
	}

	public void setPhoneField(JFormattedTextField phoneField) {
		this.phoneField = phoneField;
	}

	public JTextField getAdresField() {
		return adresField;
	}

	public void setAdresField(JTextField adresField) {
		this.adresField = adresField;
	}

	public JTextField getZipcodeField() {
		return zipcodeField;
	}

	public void setZipcodeField(JTextField zipcodeField) {
		this.zipcodeField = zipcodeField;
	}

	public JTextField getCityField() {
		return cityField;
	}

	public void setCityField(JTextField cityField) {
		this.cityField = cityField;
	}

	public JPasswordField getPasswordField() {
		return passwordField;
	}

	public void setPasswordField(JPasswordField passwordField) {
		this.passwordField = passwordField;
	}

	public JPasswordField getConfirmPassField() {
		return confirmPassField;
	}

	public void setConfirmPassField(JPasswordField confirmPassField) {
		this.confirmPassField = confirmPassField;
	}

	public JButton getConfirmButton() {
		return confirmButton;
	}

	public void setConfirmButton(JButton confirmButton) {
		this.confirmButton = confirmButton;
	}

	public JButton getResetButton() {
		return cancelButton;
	}

	public void setResetButton(JButton resetButton) {
		this.cancelButton = resetButton;
	}
	
}
